/// <reference path="../../../Controls/Additions/Addition.js" />

Type.registerNamespace("BM");

// Descriptor object

BM.Descriptor = function(item, additionNode) {
    ///	<summary>
    ///	Descriptor is an Addition that takes responsibility of item description, displayed in tabs, titles or key references    
    ///	</summary>
    ///	<returns type="BM.Descriptor" />    
    BM.Descriptor.initializeBase(this, [item, additionNode]);
}

BM.Descriptor.prototype = {
    load: function() {
        BM.Descriptor.callBaseMethod(this, 'load');
        this.item.descriptor = this;        
    },

    addDescriptionChanged: function(handler) {
        /// <summary>
        /// Add an event handler for the descriptionChanged event
        /// </summary>
        /// <param name="handler" type="Function" mayBeNull="false">
        /// Event handler
        /// </param>
        /// <returns />
        this.getItem().addDescriptionChanged(handler);
    },

    removeDescriptionChanged: function(handler) {
        /// <summary>
        /// Remove an event handler from the descriptionChanged event
        /// </summary>
        /// <param name="handler" type="Function" mayBeNull="false">
        /// Event handler
        /// </param>
        /// <returns />
        this.getItem().removeDescriptionChanged(handler);
    },

    raiseDescriptionChanged: function(eventArgs) {
        /// <summary>
        /// Raise the descriptionChanged event
        /// </summary>
        /// <param name="eventArgs" type="Sys.EventArgs" mayBeNull="false">
        /// Event arguments for the descriptionChanged event
        /// </param>
        /// <returns />        
        this.getItem().raiseDescriptionChanged(eventArgs);
    },

    getDescription: function() {
    }
}

BM.Descriptor.registerClass("BM.Descriptor", BM.Addition);

// DefaultDescriptor object

BM.DefaultDescriptor = function(item) {
    BM.DefaultDescriptor.initializeBase(this, [item]);
}

BM.DefaultDescriptor.prototype = {

    getDescription: function() {
        if (this.item.getValue() != null) {
            return this.item.getValue();
        }
        return this.item.getName();
    }
}

BM.DefaultDescriptor.registerClass("BM.DefaultDescriptor", BM.Descriptor);